package com.eternal.util.page;/**
 * @Title: PageUtil
 * @ProjectName notest
 * @Description: TODO
 * @author Eternal
 * @date 2018/11/3 20:09
 */

import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @Class PageUtil
 * @Description: TODO
 * @Author Eternal
 * @Version
 * @date 2018/11/3 20:09
 */
@Data
public class PageVo<T> implements Serializable {

    private List<T> records;
    private long total;

    /**
     * 每页显示条数，默认 10
     */
    private int size = 10;

    /**
     * 总页数
     */
    private long pages;

    /**
     * 当前页
     */
    private int current = 1;

    public PageVo() {
        super();
    }

    public PageVo(List<T> records, Pagination pagination) {
        this.total = pagination.getTotal();
        this.pages = pagination.getPages();
        this.records = records;
        this.size = pagination.getSize();
        this.current = pagination.getCurrent();
    }

    @Override
    public String toString() {
        return "PageVo{" +
                "records=" + records +
                ", total=" + total +
                ", size=" + size +
                ", pages=" + pages +
                ", current=" + current +
                '}';
    }
}
